package tq.com.tqteacher.discuss.adapter;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.ViewGroup;

import java.util.ArrayList;

import tq.com.tqteacher.discuss.factory.TQDiscussFactory;
import tq.com.tqteacher.discuss.vh.IDiscussSelectItemClickListener;
import tq.com.tqteacher.model.TQCommentOverInfoModel;

public class TQManagerMsgAdapter extends TQMsgAdapter implements IDiscussSelectItemClickListener {

    public TQManagerMsgAdapter(Context pContext){
        super(pContext);
    }
    @NonNull
    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup pViewGroup, int pI) {
        return TQDiscussFactory.getSelectInstance(pI, mContext, pViewGroup);
    }

//    @Override
//    public void onBindViewHolder(@NonNull RecyclerView.ViewHolder pViewHolder, int pI) {
//
//    }
//
//    @Override
//    public int getItemViewType(int position) {
//        if(position %2 == 0) return TQDiscussFactory.TYPE_Left;
//        return TQDiscussFactory.TYPE_RIGHT;
//    }
//
//    @Override
//    public int getItemCount() {
//        return 0;
//    }


    @Override
    public void selectMessage(TQCommentOverInfoModel.TQCommentInfoModel pInfoModel, boolean selected) {
        if(mSelectedChangeListener == null) return;
        mSelectedChangeListener.dataChange(pInfoModel, selected);
    }

    @Override
    public boolean isSelected(TQCommentOverInfoModel.TQCommentInfoModel pInfoModel) {
        if(mSelectedChangeListener == null) return false;
        return mSelectedChangeListener.isSelected(pInfoModel);
    }

    public void setSelectedChangeListener(ISelectedChangeListener pChangeListener){
        mSelectedChangeListener = pChangeListener;
    }
    private ISelectedChangeListener mSelectedChangeListener ;
    public interface ISelectedChangeListener{
        void dataChange(TQCommentOverInfoModel.TQCommentInfoModel pInfoModel, boolean selected);

        boolean isSelected(TQCommentOverInfoModel.TQCommentInfoModel pInfoModel);
    }

    public void removeSelect(ArrayList<TQCommentOverInfoModel.TQCommentInfoModel> pInfoModels){
        mCommentInfoModels.removeAll(pInfoModels);
        notifyDataSetChanged();
    }
}
